/*
 * (C)opyright 2012 ssb Software Service und Beratung GmbH
 */
package net.slidinglive.utilities.adapter;

import java.util.List;

import net.slidinglive.utilities.fragment.AbstractFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

/**
 * @author Sebastian Hoffmann <bo.hoffi@gmail.com>
 */
public class SectionPagerAdapter
        extends FragmentPagerAdapter {

    private final List<AbstractFragment> pages;

    public SectionPagerAdapter(final FragmentManager fm, final List<AbstractFragment> pages) {

        super(fm);
        this.pages = pages;
    }

    @Override
    public Fragment getItem(int i) {

        return this.pages.get(i);
    }

    @Override
    public int getCount() {

        return this.pages.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {

        return ((AbstractFragment) this.getItem(position)).getTitle();
    }
}